import Vue from 'vue'
import App from './App'

//国际化
import RU from '@/lang/ru-RU.json'
import CN from '@/lang/zh-CN.json'
import {
	LOCALE,
	HTTP_IMG_UTL
} from "@/config/app"
import VueI18n from 'vue-i18n' // v8.x

import httpInterceptor from '@/common/http.interceptor.js'
import httpApi from '@/common/http.api.js'

// 分享
import share from "@/common/share.js"


// import update from "@/pages/update.vue";
// Vue.component("update", update)



import {systemInfo} from '@/common/systemInfo.js'
Vue.prototype.$SystemInfomations = systemInfo()
Vue.prototype.$navHeight = systemInfo().navHeight + systemInfo().statusBarHeight

Vue.mixin(share)

import Notification from "@/components/Notification.vue"
Vue.component("Notification", Notification)

import VueCompositionAPI from "@vue/composition-api";
Vue.use(VueCompositionAPI);

Vue.prototype.log = (d) => {
	
}
Vue.prototype.$eventBus = new Vue()
Vue.prototype.serverImageUrl = (path) => {
	return HTTP_IMG_UTL.substr(0, HTTP_IMG_UTL.length - 1) + path
}
Vue.prototype.toast = (title) => {
	uni.showToast({
		title,
		icon: "none"
	})
}

Vue.prototype.langKey = (item, key) => {
	return uni.getStorageSync("lang") == 'zh' ? item[key] : item[key + '_ru']
}

// 获取配置信息
Vue.prototype.$onLaunched = new Promise(resolve => {
	Vue.prototype.$isResolve = resolve
})
const messages = {
	'ru': RU,
	'zh': CN,
}
let i18nConfig = {
	locale: LOCALE, // 获取已设置的语言
	messages,
	silentTranslationWarn: true, // 去除国际化警告
}
Vue.use(VueI18n)

const i18n = new VueI18n(i18nConfig)
Vue.config.productionTip = false
Vue.prototype._i18n = i18n
App.mpType = 'app'

// 是否登录
Vue.prototype.$isLogin = function() {
	return uni.getStorageSync("mobile")
}

import store from './store'
Vue.prototype.$store = store
// 引入全局uView
import uView from 'uview-ui'

Vue.use(uView);

import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
Vue.component('uni-icons', uniIcons);

import uniSection from '@/uni_modules/uni-section/components/uni-section/uni-section.vue'
Vue.component('uni-section', uniSection);
const app = new Vue({
	i18n,
	store,
	...App,
	share
})


// http请求拦截器
Vue.use(httpInterceptor, app)
// api集中管理
Vue.use(httpApi, app)
app.$mount()

export default app

